<template>
  <div class="login-container">
    <!-- 登录框 -->
    <div class="login-box">
      <!-- logo区域 -->
      <div class="logo">
        <img src="../assets/logo.png">
      </div>
      <!-- 登录表单 -->
      <el-form :model="loginForm" :rules="loginFormRules" ref="loginFormRef">
        <el-form-item prop="username">
          <!-- 使用prefix-icon="iconfont icon-user"设置小图标 -->
          <el-input placeholder="请输入登录名称" prefix-icon="iconfont icon-user" v-model="loginForm.username">
          </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <!-- 使用<i slot="suffix" class="iconfont icon-3702mima"></i>设置小图标 -->
          <el-input placeholder="请输入登录密码" v-model="loginForm.password" :type="ispwd ? 'password' : 'text'">
            <i slot="prefix" :class="['iconfont', ispwd ? 'icon-3702mima' : 'icon-showpassword']" @click="ispwd = !ispwd"></i>
          </el-input>
        </el-form-item>
        <!-- 按钮组 -->
        <el-row>
          <el-col>
            <el-button type="primary" @click="login">登录</el-button>
            <el-button type="info" @click="reset">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
  // 导入属于自己的mixins文件
  import mix from './Login-mixins.js'
  export default {
    mixins: [mix]
  }
</script>

<style lang="less" scoped>
  // 要让style标签支持less语法: 1. 添加lang="less"属性, 2. 安装cnpm i less-loader less -D
  .login-container {
    height: 100%;
    background-color: #2B4B6B;
    .login-box {
      position: absolute;
      top: 20%;
      left: 50%;
      width: 450px;
      height: 304px;
      background-color: #fff;
      border-radius: 4px;
      transform: translateX(-50%);
      .logo {
        position: relative;
        top: -50px;
        left: 50%;
        width: 120px;
        height: 120px;
        padding: 10px;
        background-color: #fff;
        border: 1px solid #eee;
        box-shadow: 0 1px 6px #eee;
        border-radius: 50%;
        transform: translateX(-50%);
        img {
          width: 100%;
          height: 100%;
          background-color: #eee;
          border-radius: 50%;
        }
      }
      .el-form {
        padding: 15px;
        position: relative;
        top: -40px;
        .icon-3702mima,
        .icon-showpassword {
          transition: all .5s;
          cursor: pointer;
          &:hover {
            color: darkred;
          }
        }
      }
      .el-col {
        display: flex;
        justify-content: flex-end;
      }
    }
  }
</style>
